`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    14:49:07 11/02/2012 
// Design Name: 
// Module Name:    TRIG_UNIT 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module TRIG_UNIT #(parameter LOG_CYCLE=8, CYCLE=160, WIDTH=16, TRES=2)
(
	
	 input clk_r_x,
	 input clk_r_len_x,
	 input rst,
	 input strength_detect,
	 input signed [WIDTH-1:0] ch1_r,
	 input signed [WIDTH-1:0] ch1_i,
	 input signed [WIDTH-1:0] ch2_r,
	 input signed [WIDTH-1:0] ch2_i,
	 output trig	 
	 );
	 
	 wire signed[WIDTH+WIDTH+1-1:0] coef_numerator;
	 wire signed[WIDTH+WIDTH-1:0] coef_denominator;
	 
	 CROSS_CORR_UNIT #(LOG_CYCLE, CYCLE , WIDTH) U_cross //cycle = 160
	 (	
		.clk_r_x(clk_r_x),
		.clk_r_len_x(clk_r_len_x),
      .rst(rst),
	   .a_r(ch1_r),
      .a_i(ch1_i),
      .b_r(ch2_r),
      .b_i(ch2_i),
	   .coef_numerator(coef_numerator),
		.coef_denominator(coef_denominator)
		);
		
	TRIG_DECIDE_UNIT #(WIDTH, TRES, LOG_CYCLE, CYCLE) U_trig_decide
	(
		.clk(clk_r_x),
		.rst(rst),
		.strength_detect(strength_detect),
		.coef_numerator(coef_numerator),
		.coef_denominator(coef_denominator),
		.trig(trig)
		);
		
endmodule
		


